#ifndef WATERCRAFT_CLIENT_H
#define WATERCRAFT_CLIENT_H 1

#include "SDL/SDL.h"
#include "SDL/SDL_net.h"
#include "SDL/SDL_thread.h"
#include "SDL/SDL_mutex.h"
#include <string>
#include <deque>

#include "zlib.h"
#include "constants.h"

class Client
{
	public:
		Client();
		Client(int id, std::string name, std::string sname, int x, int y, int z, char rx, char ry, TCPsocket socket, bool admin);
		~Client();
		
		void send_map(char* map, int len);
		void append_packet(char* buffer, int len);
		
		bool isFrozen();
		bool isAdmin();
		bool isMoved();
		void set_moved(bool val);
		
		TCPsocket getSocket();
		
		void get_pos_old(int* x, int* y, int* z, int* rx, int* ry);
		void get_pos(int* x, int* y, int* z, int* rx, int* ry);
		void set_pos(int x, int y, int z, int rx, int ry);
		void set_pos_old(int x, int y, int z, int rx, int ry);
		void move(int x, int y, int z, int rx, int ry);
		
		std::string getName();
		int socket_ready();
		
		int send_packet();
	
		bool mute;
		
		void get_last_block(int index, int* x, int* y, int* z, int* type);
		void set_last_block(int index, int x, int y, int z, int type);
	
	private:
		TCPsocket socket;
		
		int x,y,z,rx,ry;
		int ox,oy,oz,orx,ory;
		
		bool admin;
		bool frozen;
		bool moved;
		
		int id;
		
		std::string name;
		std::string sname;		

		char packet[1024];
		int packet_size;

		int last_block[2][4];
};

#endif
